﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;

namespace WcfCore
{
	public interface IWcfOneWayLatencyTestServiceContract
	{
		void OneWayLatencyTest();
	}

	public interface IWcfServiceContract : IWcfOneWayLatencyTestServiceContract
	{
		void Initialize(WcfTestInput input);
		void ReceiveData(byte[] data);
		void ReceiveSC(SimpleContainer container);
		void ReceiveAC(AdvancedContainer container);
		void ReceiveStream(Stream data);
		void ReceiveText(string text);
		void ReceiveSTC(SimpleTextContainer container);
		void ReceiveATC(AdvancedTextContainer container);
		void ReceiveDataThrowException(byte[] data);
		void ReceiveDataTransactional(byte[] data);
		void TerminateSession();
	}

	//[ServiceContract(Namespace = "http://Wcf/Services/DuplexCallbackContract", SessionMode = SessionMode.Required)]
	//public interface IWcfDuplexCallbackContract
	//{
	//    void CallbackReceiveDataDCS(byte[] bytes);
	//}

	[Serializable]
	public class SimpleContainer
	{
		public SimpleContainer()
		{
		}

		public SimpleContainer(byte[] data)
		{
			_data = data;
		}

		private byte[] _data;
		public byte[] Data
		{
			get
			{
				return _data;
			}
			set
			{
				_data = value;
			}
		}
	}

	[Serializable]
	public class AdvancedContainer
	{
		public AdvancedContainer()
		{
		}

		public AdvancedContainer(byte[] data)
		{
			_data = data;
		}

		public AdvancedContainer(byte[] data, AdvancedContainer[] containers)
			: this(data)
		{
			_containers = containers;
		}

		private byte[] _data;
		[DataMember]
		public byte[] Data
		{
			get
			{
				return _data;
			}
			set
			{
				_data = value;
			}
		}

		private AdvancedContainer[] _containers;
		public AdvancedContainer[] Containers
		{
			get
			{
				return _containers;
			}
			set
			{
				_containers = value;
			}
		}
	}
	[Serializable]
	public class SimpleTextContainer
	{
		public SimpleTextContainer()
		{
		}

		public SimpleTextContainer(string text)
		{
			_text = text;
		}

		private string _text;
		public string Text
		{
			get
			{
				return _text;
			}
			set
			{
				_text = value;
			}
		}
	}

	[Serializable]
	public class AdvancedTextContainer
	{
		public AdvancedTextContainer()
		{
		}

		public AdvancedTextContainer(string text)
		{
			_text = text;
		}

		public AdvancedTextContainer(string text, AdvancedTextContainer[] containers)
			: this(text)
		{
			_containers = containers;
		}

		private string _text;
		[DataMember]
		public string Text
		{
			get
			{
				return _text;
			}
			set
			{
				_text = value;
			}
		}

		private AdvancedTextContainer[] _containers;
		public AdvancedTextContainer[] Containers
		{
			get
			{
				return _containers;
			}
			set
			{
				_containers = value;
			}
		}
	}
}
